package com.xinggq.common.enums;

import java.util.HashSet;
import java.util.Set;
import lombok.Getter;

/**
 * 响应错误代码
 *
 * @author zhangyajun
 * @since 2023/9/20 09:55
 */
@Getter
public enum ResponseEnum {

  //请求相关
  SUCCESS(1000, "SUCCESS"),
  //请求错误
  REQUEST_FAIL(900, "fail"),
  APP_ID_NOT_FOUND(901, "应用ID不能为空"),
  //参数错误
  PARAMS_ERROR(2001, "PARAMS ERROR"),
  // 未知的参数
  INVALID_PARAM(2002, "INVALID PARAM"),
  //未知错误
  UNKNOWN_ERROR(3001, "UNKNOWN ERROR"),
  //鉴权失败
  AUTH_FAILURE(3002, "AUTH FAILURE"),
  //数据为空
  DATA_IS_NULL(1008, "数据为空"),
  //参数为空
  PARAM_IS_NULL(1009, "参数为空"),
  //IP重复
  IMPORT_IP_EXITS(1011, "IP重复"),
  //名称已存在
  NAME_IS_EXISTS(1016, "名称已存在"),
  //短信验证码错误
  DUANXIN_CODE_ERROR(1017, "短信验证码错误"),

  //请求url相关
  URL_ERROR(5001, "URL ERROR"),
  //响应数据异常
  RESPONSE_DATA_ERROR(5002, "RESPONSE DATA ERROR"),
  //外部请求错误
  EXTERNAL_REQUEST_ERROR(3004, "EXTERNAL_REQUEST_ERROR"),
  //服务不可用
  SERVICE_UNAVAILABLE(3005, "服务不可用"),

  //堆栈查询错误
  STACK_QUERY_ERROR(4098, "STACK_QUERY_ERROR"),
  STACK_DATA_EXCEPTION(4097, "STACK_DATA_EXCEPTION"),

  /* 数据库操作相关 */
  UPDATE_ERROR(4000, "UPDATE ERROR"),
  UPDATE_FAIL(4001, "UPDATE FAIL"),
  QUERY_ERROR(4002, "QUERY ERROR"),
  QUERY_EMPTY(4003, "DATA EMPTY"),
  DELETE_ERROR(4005, "DELETE ERROR"),
  DELETE_FAIL(4006, "DELETE FAIL"),
  INSERT_ERROR(4007, "INSERT ERROR"),
  INSERT_FAIL(4008, "INSERT FAIL"),
  SQL_EXCEPTION(4205, "SQL_EXCEPTION"),

  /* 文件相关 */
  //文件类型错误
  FILE_TYPE_ERROR(4009, "FILE TYPE ERROR"),
  //文件上传错误
  FILE_UPLOAD_ERROR(4701, "FILE UPLOAD FAIL"),
  //文件未创建错误
  NOT_FOUNDED_FILE_ERROR(4010, "NOT FOUNDED FILE ERROR"),
  //文件为空错误
  FILE_IS_EMPTY(4032, "FILE IS EMPTY"),
  // 文件压缩错误
  FILE_COMPRESS_ERROR(4033, "FILE COMPRESS ERROR"),

  /* 认证，权限相关 */
  // 验证码失效
  AUTH_VERIFYCODE_EXPIRE(4110, "VERIFYCODE EXPIRE"),
  // 验证码错误
  AUTH_VERIFYCODE_ERROR(4111, "VERIFYCODE ERROR"),
  // 超出错误登录次数
  ABNORMAL_LOGIN_ERROR(4112, "ABNORMAL LOGIN ERROR"),
  // 超出错误登录次数
  ABNORMAL_LOGIN_ERROR_LOCK(4113, "ABNORMAL LOGIN ERROR LOCK"),
  // 用户不存在
  AUTH_USER_NOT_FOUND(4101, "账号不存在"),
  // 用户被禁用
  AUTH_USER_DISABLE(4102, "USER DISABLE"),
  // 用户名或密码错误
  AUTH_USER_ERROR(4103, "USER OR PASSWORD ERROR"),
  // 没有权限
  AUTH_NO_PERMISSION(4104, "NO PERMISSION"),
  // 认证错误
  AUTH_ERROR(4105, "AUTH ERROR"),
  // 用户未绑定微信
  AUTH_USER_NOT_BIND(4106, "USER NOT BIND"),
  // 用户企业被冻结
  AUTH_USER_TENANT_DISABLE(4107, "USER TENANT DISABLE"),
  // 原密码输入错误
  AUTH_PASSWORD_ERROR(4111, "PASSWORD ERROR"),
  //安全相关
  SECURITY_ERROR(5001, "UNSAFE REQUEST"),


  /* 企业企业相关 */
  //
  //名称已存在
  TENANT_NAME_EXISTS(6001, "企业名称已存在"),
  TENANT_PHONE_EXISTS(6002, "手机号已存在"),
  TENANT_REG_PENDING(6003, "注册审核中"),
  TENANT_REG_REJECTED(6004, "注册审核拒绝"),
  TENANT_REG_NAME_ALREADY_APPLY(6005, "该企业名称已提交注册申请"),
  TENANT_REG_PHONE_ALREADY_APPLY(6005, "该手机号已提交注册申请"),

  /* 员工相关 */
  EMPLOYEE_INVITE_EXPIRE(7001, "员工邀请码已过期"),

  /* 订单相关 */
  //
  /* 播放Token */
  VIDEO_TOKEN_CHECKLOGIN(600, "您的帐号正在其它设备上登录并学习，同一时间内只能学习一门课程");

  public final int code;
  public final String msg;


  ResponseEnum(int code, String msg) {
    this.code = code;
    this.msg = msg;
  }

  public static Set<Integer> getValues() {
    Set<Integer> codes = new HashSet<>();
    for (ResponseEnum value : ResponseEnum.values()) {
      codes.add(value.code);
    }
    return codes;
  }
}
